import { getAllPostIds, getPostData } from '@/lib/posts'
import Head from 'next/head'
import React from 'react'
interface Props {
  title: string
  id: string
  date: string
  contentHtml: string | TrustedHTML
}
export default function Post({ postData }: { postData: Props }) {
  return (
    <div>
      <Head>
        <title>{postData.title}</title>
      </Head>
      {postData.title}
      <br />
      {postData.id}
      <br />
      {postData.date}
      <br />
      <div
        className=""
        dangerouslySetInnerHTML={{ __html: postData.contentHtml }}
      />
    </div>
  )
}
export async function getStaticPaths() {
  const paths = getAllPostIds()
  return {
    paths,
    fallback: false,
  }
}

export async function getStaticProps({ params }: { params: { id: string } }) {
  const postData = await getPostData(params.id)
  return {
    props: {
      postData,
    },
  }
}
